package com.xrui.hbase.schema.desc;


import com.google.common.base.Preconditions;
import com.xrui.hbase.schema.SchemaType;


public class CellSchemaDesc {
    private SchemaType type;
    private String id;
    private String schema;
    private String compression;
    private String converter;

    public SchemaType getType() {
        return type;
    }

    public void setType(SchemaType type) {
        this.type = type;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getSchema() {
        return schema;
    }

    public void setSchema(String schema) {
        this.schema = schema;
    }

    public String getCompression() {
        return compression;
    }

    public void setCompression(String compression) {
        this.compression = compression;
    }

    public String getConverter() {
        return converter;
    }

    public void setConverter(String converter) {
        this.converter = converter;
    }

    public static class CellSchemaBuilder {
        private SchemaType mSchemaType;
        private String mId;
        private String mSchema;
        private String mCompression;
        private String mConverter;

        public static CellSchemaBuilder newBuilder() {
            return new CellSchemaBuilder();
        }

        public CellSchemaBuilder withType(SchemaType type) {
            mSchemaType = type;
            return this;
        }

        public CellSchemaBuilder withID(String id) {
            mId = id;
            return this;
        }

        public CellSchemaBuilder withSchema(String schema) {
            mSchema = schema;
            return this;
        }

        public CellSchemaBuilder withCompression(String compression) {
            mCompression = compression;
            return this;
        }

        public CellSchemaBuilder withConverter(String converterName) {
            mConverter = converterName;
            return this;
        }

        public CellSchemaDesc build() {
            Preconditions.checkNotNull(mSchemaType);
            CellSchemaDesc schemaDesc = new CellSchemaDesc();
            schemaDesc.setType(mSchemaType);
            schemaDesc.setSchema(mSchema);
            schemaDesc.setId(mId);
            schemaDesc.setCompression(mCompression);
            schemaDesc.setConverter(mConverter);
            return schemaDesc;
        }
    }
}
